from functools import lru_cache
from typing import Annotated

from fastapi import Depends
from loguru import logger

from app.config import Settings
from app.internal.inference import Inference


@lru_cache
def get_settings() -> Settings:
    settings = Settings()
    logger.info(f"Settings: {settings}")

    return settings


def get_inference(settings: Annotated[Settings, Depends(get_settings)]) -> Inference:
    inference = Inference(
        settings.weight_path, settings.save_result, settings.save_path
    )
    inference.start()

    return inference
